package cn.lccabc.workflow.controller;

import cn.lccabc.workflow.entity.ReAttend;
import cn.lccabc.workflow.service.ReAttendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by L on 2018/4/23.
 */
@Controller
@RequestMapping(value = "reAttend")
public class ReAttendController {

    @Autowired
    private ReAttendService reAttendService;

    @RequestMapping(value = "start")
    public void startReAttendFlow(@RequestBody ReAttend reAttend, HttpSession session){
//        User user = (User) session.getAttribute("userinfo");
//        reAttend.setRe_attend_starter(user.getReal_name());
        reAttend.setRe_attend_starter("laoli");
        reAttendService.startReAttendFlow(reAttend);
    }

    @RequestMapping(value = "list")
    @ResponseBody
    public List<ReAttend> listReAttendFlow(){
        String username = "laoli666";
        List<ReAttend> reAttends = reAttendService.listTasks(username);
        return reAttends;
    }

    @RequestMapping(value = "approve")
    public void approveReAttendFlow(@RequestBody ReAttend reAttend){
        reAttendService.approve(reAttend);
    }

}
